package com.bestcem.xm.txtanls.enums;

import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 话题类型枚举类
 *
 * @author liheng
 * @version v1.0
 * @date 2021/5/10-17:02
 */
@Getter
public enum TopicTypeEnum {

    /**
     * 话题
     */
    TOPIC(1, "话题"),
    /**
     * 话题组
     */
    GROUP(0, "话题组");

    private final String name;

    private final int index;

    TopicTypeEnum(int index, String name) {
        this.name = name;
        this.index = index;
    }

    /**
     * 枚举值校验方法，校验是否是合法的枚举值
     *
     * @param index 枚举index
     * @return 是否合法，false-不合法，true-合法
     */
    public static boolean valid(Integer index) {
        if (!ObjectUtils.isEmpty(index)) {
            if (index == 0 || index == 1) {
                return true;
            }
        }
        return false;
    }
}
